package com.aaa.mbs.controller;

import com.aaa.common.util.Result;
import com.aaa.mbs.entity.Coupon;
import com.aaa.mbs.service.feign.CouponFeignService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: 10178
 * @Date: 2021/1/23 16:08
 * @Description:
 */
@RestController
@RequestMapping("/coupon")
public class CouponController {

    @Autowired
    private CouponFeignService couponFeignService;

    @PostMapping("/queryAll")
    public Result<PageInfo<Coupon>> queryAll(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestBody Coupon coupon) {
        return couponFeignService.queryAll(pageNo, pageSize, coupon);
    }

    @PutMapping("/update")
    public Result<Coupon> update(@RequestBody Coupon coupon){
        System.out.println(coupon.getStartTime());
        System.out.println(coupon.getEndTime());
        return couponFeignService.update(coupon);
    }

    @PostMapping("/insert")
    Result<Coupon> insert(@RequestBody Coupon coupon){
        System.out.println(coupon.getStartTime());
        System.out.println(coupon.getEndTime());
        return couponFeignService.insert(coupon);
    }
}
